package com.dg11185.nearshop.db.entity;

import com.baidu.location.BDLocation;
import com.dg11185.libs.ormlite.field.DatabaseField;
import com.dg11185.libs.ormlite.table.DatabaseTable;

/**
 * 
 * @author：Daibo
 * @time：2014-7-2 下午5:26:55
 */
@DatabaseTable(tableName = DbConstant.LOCATION)
public class Location {

    @DatabaseField(generatedId = true)
    private int id;

    @DatabaseField(width = 20)
    public double latitude;

    @DatabaseField(width = 20)
    public double longitude;

    @DatabaseField(width = 20)
    public double altitude;

    @DatabaseField(width = 20)
    public int satellitesNum;

    @DatabaseField(width = 20)
    public float speed;

    @DatabaseField(width = 20)
    public float radius;

    @DatabaseField(width = 20)
    public float direction;

    @DatabaseField(width = 50)
    public String addrStr;

    @DatabaseField(width = 20)
    public String province;

    @DatabaseField(width = 20)
    public String cityName;

    @DatabaseField(width = 20)
    public String cityCode;

    @DatabaseField(width = 20)
    public String district;

    public Location(){
        
    }
    
    public Location(BDLocation location) {
        this.latitude = location.getLatitude();
        this.longitude = location.getLongitude();
        this.altitude = location.getAltitude();
        this.satellitesNum = location.getSatelliteNumber();
        this.speed = location.getSpeed();
        this.radius = location.getRadius();
        this.addrStr = location.getAddrStr();
        this.province = location.getProvince();
        this.cityName = location.getCity();
        this.cityCode = location.getCityCode();
        this.district = location.getDistrict();
    }
    
    /**只能设置BDLocation中的部分数据，使用的时候需要小心*/
    public BDLocation getBdLocation(){
        BDLocation location = new BDLocation();
        location.setLatitude(altitude);
        location.setLongitude(longitude);
        location.setAltitude(altitude);
        location.setSatelliteNumber(satellitesNum);
        location.setSpeed(speed);
        location.setRadius(radius);
        location.setAddrStr(addrStr);
        return location;
    }
}
